<?
$caminhoFora ='/home/luizmore/www';
if ($_SERVER['SERVER_NAME'] == "localhost") { 
	$caminhoSite = $DOCUMENT_ROOT;
}else{ 
	$caminhoSite = $caminhoFora;
}
 set_include_path ($caminhoSite."/moreira/admin/scripts/".PATH_SEPARATOR.$caminhoSite."/moreira/admin/".PATH_SEPARATOR.$caminhoSite."/moreira/admin/includes/");
	
	require "_onStartPage.php";
	include_once "_clsAllAction.php";


	
	$objAllAction = new clsAllAction();
	
	
	if( $action == "delete"){
	
		$objAllAction->deleteFiles();
	
	}
	
				
	$stmt = $objAllAction->getDownloadFiles( $KEY, $ID_PARAMETRO);
	$rsDownloads = $objDB->DBDadosRegistros($stmt);
	
?>
<link rel="stylesheet" href="/moreira/admin/fontes.css" type="text/css">
<script>
	function removeFile( ID, EXTENSAO ){
	
		var confirma = confirm("Tem certeza que deseja remover este arquivo?");
		if(confirma){
			document.frmDownload.ID_DOWNLOAD.value = ID;
			document.frmDownload.EXTENSAO.value = EXTENSAO;
			document.frmDownload.action.value = "delete";
			document.frmDownload.submit();
		}else{
			return;
		}
	
	}
</script>
<body class="<?=$STYLE?>">
<form name="frmDownload" method="post" >								
<input type="hidden" readonly="" name="ID_DOWNLOAD" />
<input type="hidden" readonly="" name="EXTENSAO" />
<input type="hidden" readonly="" name="action" />
<a href="#" class="menuLinks" onclick="window.open('/moreira/admin/includes/insert_download.php?PARAMETRO=<?=$KEY?>&ID_PARAMETRO=<?=$ID_PARAMETRO?>','','width=300, height=200')"><img src="/moreira/admin/imgs/add.gif" border="0" />Adicionar Arquivo</a>
<table width="50%" border="1" class="tabelaSimples">
	<tr>
		<td align="center" width="10%" style="color:#996600">Excluir</td>
		<td align="center" width="13%" style="color:#996600">Download</td>
		<td align="center" style="color:#996600">Arquivo</td>
	</tr>
<?
	foreach( $rsDownloads as $rsDownload ){
?>	
	<tr>
		<td align="center">
			<img src="<?=PATH_IMGS?>excluir.gif" onclick="removeFile(<?=$rsDownload->ID_DOWNLOAD?>, '<?=$rsDownload->EXTENSAO?>' )" border="0" style="cursor:pointer" alt="excluir" title="excluir">
		</td>
		<td align="center">
			<a target="_blank" href="/moreira/admin/includes/download.php?arquivo=file_<?=$rsDownload->ID_DOWNLOAD?>.<?=$rsDownload->EXTENSAO?>"><img src="/moreira/admin/imgs/download.jpg" style="cursor:pointer" border="0" alt="Download" title="download" /></a>
		</td>
		<td>
			<?=strtolower($rsDownload->NOME)?>
		</td>
	</tr>
<?
	}
?>		
</table>		
</form>